package org.sprogram.utils
{
	public class StringUtils
	{
		/**
		 * 文本竖起来 
		 */
		public static function textToV(str:String):String
		{
			while(str.indexOf(" ") != -1)
			{
				str = str.replace(" ", "");
			}
			while(str.indexOf("\n") != -1)
			{
				str = str.replace("\n", "");
			}
			while(str.indexOf("\r") != -1)
			{
				str = str.replace("\r", "");
			}
			var str2:String = "";
			for(var i:int = 0; i < str.length; i++)
			{
				str2 += str.charAt(i) +"\n";
			}
			return str2;
		}
		
		/**
		 * 清除前后回车和 文本内的多回车
		 */
		public static function cleanEnterKey(str:String):String
		{
			while (str.indexOf("\r") != -1)
			{
				str = str.replace("\r", "\n");
			}
			var i:int = 0;
			
			while(str.substr(i,1) == "\n")
			{
				str = str.substr(1);
			}
			
			while (str.indexOf("\n\n") != -1)
			{
				str = str.replace("\n\n", "\n");
			}
			if(str.substr(str.length - 1) == "\n")
			{
				str = str.substr(0, str.length - 1);
			}
			return str;
		}
	}
}